#ifndef __MP_LOAD_CONFIG_H__
#define __MP_LOAD_CONFIG_H__

#include <string>
#include <vector>
#include <fstream>

#include "logger.h"

struct NodeConfig {
    std::string host_name;
    std::string host_ip;
};

struct ApiGatewayConfig {
    int http_server_port      = 40001;
    int websocket_server_port = 40002;
    int mqtt_broker_port      = 40003;
    int mqtt_retain_max       = 32;
};

struct ServiceDiscoveryConfig {
    int service_register_port     = 40010;
    int service_sync_interval     = 5;
    int service_heartbeat_timeout = 15;
};

struct LoadBalanceConfig {
    int loadbalance_method = 0;
};

struct GazellaConfig {
    int http_server_port      = 41001;
    int websocket_server_port = 41002;
};

struct TransmissionPlugin {
    std::string name;
    std::string path;
    std::string loglevel;
    std::string runmode;
    bool        softbus;
};

struct TransmissionNodeInfo {
    NodeConfig node;

    int port;  //listen port
};

struct TransmissionConfig {
    TransmissionPlugin   plugin;
    TransmissionNodeInfo local;
    std::vector<TransmissionNodeInfo> remote_list;
};

class LoadConfig {
private:
    LoadConfig();
    ~LoadConfig();

public:
    static LoadConfig* get_instance();

    int load(const std::string& config_file_path);

    const std::string& config_file_path();

    const ApiGatewayConfig&       apigateway_config();
    const ServiceDiscoveryConfig& servicediscovery_config();
    const LoadBalanceConfig&      loadbalance_config();

    const GazellaConfig& gazella_config();

    const TransmissionPlugin&   transmission_plugin();
    const TransmissionNodeInfo& transmission_local_info();
    const std::vector<TransmissionNodeInfo>& transmission_remote_list();

private:
    std::string m_config_file_path;

    Logger *m_logger;

    ApiGatewayConfig       m_apigateway_config;
    ServiceDiscoveryConfig m_servicediscovery_config;
    LoadBalanceConfig      m_loadbalance_config;

    GazellaConfig          m_gazella_config;

    TransmissionConfig     m_transmission_config;
};

#endif